package com.atguigu.boot.controller;

import com.atguigu.boot.bean.Car;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.LocalTime;

//@ResponseBody
//@Controller
//@RestController 注解包含ResponseBody、Controller
@RestController
public class HelloController {

    @Autowired
    Car car;

    @RequestMapping("/car")
    public Car car() {
        return car;
    }

    @RequestMapping("/")
    public String Handler01(){
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        LocalDateTime happenDateTime = timestamp.toLocalDateTime();// 考勤时间
        LocalTime endTime = LocalTime.parse("08:00"); // 早上上班时间 "08:00"
        LocalDateTime completeDateTime = LocalDateTime.of(happenDateTime.toLocalDate(), endTime);// 上班的时间
        java.util.Date date = java.sql.Timestamp.valueOf(completeDateTime);
        System.out.println(sdf1.format(date));
        return "hello spring boot";
    }
}
